<!doctype html>
<html lang="en"><head>
    <meta charset="utf-8">
    <title>Bootstrap Admin</title>
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!--  <link href='http://fonts.useso.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'> -->
    <link rel="stylesheet" type="text/css" href="{{ URL::asset('lib/bootstrap/css/bootstrap.css')}}">
    <link rel="stylesheet" href="{{ URL::asset('lib/font-awesome/css/font-awesome.css')}}">

    <script src="{{ URL::asset('lib/jquery-1.11.1.min.js')}}" type="text/javascript"></script>

    <script src="{{ URL::asset('lib/jQuery-Knob/js/jquery.knob.js')}}" type="text/javascript"></script>
    <script src="{{ URL::asset('lib/bootstrap/js/bootstrap.js')}}"></script>

    {{--layer引入--}}

    <script src="{{URL::asset('js/layer/layer.js')}}"></script>

    <script type="text/javascript">
        $(function() {
            $(".knob").knob();
        });
    </script>

    <link rel="stylesheet" type="text/css" href="{{ URL::asset('stylesheets/theme.css')}}">
    <link rel="stylesheet" type="text/css" href="{{ URL::asset('stylesheets/premium.css')}}">
</head>
<div class="header" style="margin-left: 5px;margin-right: 5px; ">


    <style>
        .table_style{border-left:1px solid #ccc;border-top:1px solid #ccc;}
        .table_style td{padding:10px;font-size: 14px;border-right:1px solid #ccc;border-bottom:1px solid #ccc;}
    </style>
    <table width="100%" cellpadding="0" cellspacing="0" class="table_style">
        <tr>
            <td align="right" width="120">标题</td>
            <td>{{$article->title}}</td>
        </tr>
        <tr>
            <td align="right" width="120">状态</td>
            <td>
                <div class="text-danger">
                    @if($article->status=='0')
                        <span style="color:#428bca ">待审核</span>
                    @elseif($article->status=='1')
                        <span style="color: green">通过</span>
                    @elseif($article->status=='2')
                        <span style="color: #FF0000">不通过</span>
                    @endif

                </div>
            </td>
        </tr>
        <tr>
            <td align="right" width="120">标题图</td>
            <td>
                @if($article->avatar=='')
                    无
                    @elseif($article->avatar!='')
                    <img width="200" class="img-responsive" src="{{$article->avatar}}">
                @endif

            </td>
        </tr>
        <tr>
            <td align="right" width="120">描述</td>
            <td>{{$article->desc }}</td>
        </tr>
        <tr>
            <td align="right" width="120">内容</td>
            <td>{!! $article->content !!}</td>
        </tr>
        <tr>
            <td align="right" width="120">发布时间</td>
            <td><span style="color:#428bca">{{\Carbon\Carbon::parse($article->created_at)->diffForHumans()}}</span></td>
        </tr>
    </table>


    @if($article->status==2)
    <div class="show_reason" style="padding: 10px">

        <h3></h3>
        <div>
            <div class="form-group">
                <label for="message" style="color: darkred">未通过原因:</label>
                <p>{{$reason->reason}}</p>
            </div>
            <div class="form-group">
                <label for="message" style="color: #428bca">整改意见:</label>
               <p>{{$reason->advice}}</p>
            </div>

        </div>
    </div>
        @endif
</div>







            <div class="btn_submit" style="display: none; padding: 10px">

                <h3></h3>
                <form>
                    <div class="form-group">
                        <label for="message">未通过原因*</label>
                        <textarea class="form-control" rows="4" id="reason"></textarea>
                    </div>
                    <div class="form-group">
                        <label for="message">整改意见</label>
                        <textarea class="form-control" rows="4" id="advice"></textarea>
                    </div>

                    <div class="">
                        <!-- Indicates a successful or positive action -->
                        <button type="button" class="btn btn-success" id="btn_pass">通过</button>
                        <!-- Indicates a dangerous or potentially negative action -->
                        <button type="button" class="btn btn-danger" id="btn_nopass">未通过</button>
                    </div>
                </form>
            </div>
        </div>


    </div>
</div>






</div>
<script type="text/javascript">
    $(function(){
        if('{{$article->status}}'=='0' && '{{$common_arr['super_id']}}'==1){
            $('.btn_submit').show();
        }

    })

    //通过按钮
    $('#btn_pass').click(function(){

        var actionUrl ='{{url('apply/article')}}';
        var flag = '1';
        var article_id='{{$article->id}}';
        var _token='{{csrf_token()}}';
        $.ajax({
            type:"post",
            url:'{{url('apply/article')}}',
            dataType:'json',
            data:'actionUrl='+actionUrl+'&flag='+flag+'&article_id='+article_id+'&_token='+_token,
            success: function(json){
                if(json.status_code == 200){

                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);



                }else{
                    layer.msg(json.msg);
                }
            }
        });
    })

    //不通过按钮
    $('#btn_nopass').click(function(){
        var actionUrl ='{{url('apply/article')}}';
        var flag = '0';
        var article_id='{{$article->id}}';
        var reason=$('#reason').val().trim();
        var advice=$('#advice').val().trim();


        if(reason=='' || reason==null){
            $('#reason').focus();
            layer.msg('请输入未通过原因');
            return;
        }
        var _token='{{csrf_token()}}';
        $.ajax({
            type:"post",
            url:'{{url('apply/article')}}',
            dataType:'json',
            data:'actionUrl='+actionUrl+'&flag='+flag+'&article_id='+article_id+'&reason='+reason+'&advice='+advice+'&_token='+_token,
            success: function(json){
                if(json.status_code == 200){

                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);

                }else{
                    layer.msg(json.msg);
                }
            }
        });
    })


</script>

</body>
</html>